<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" href="#" type="image/png">

  <title>Editable Table</title>

  <!--data table-->
  <link rel="stylesheet" th:href="@{/js/data-tables/DT_bootstrap.css}" />

  <link th:href="@{/css/style.css}" rel="stylesheet">
  <link th:href="@{/css/style-responsive.css}" rel="stylesheet">

  <!-- HTML5 shim和response .js IE8支持HTML5元素和媒体查询 -->
  <!--[if lt IE 9]>
  <script th:src="@{/js/html5shiv.js}"></script>
  <script th:src="@{/js/respond.min.js}"></script>
  <![endif]-->
    <script type="text/javascript">
        window.onload = function(){
            document.getElementById("show").onclick = function(){
                if (document.getElementById("hide").style.display === "none"){
                    document.getElementById("hide").style.display = "block";
                }else {
                    document.getElementById("hide").style.display = "none";
                }
            }
        }
        function Edit(){
            // 跳转形式：
            // document.("表单的name值").action = “”
            // document.("表单的name值").submit = “”
            document.pay.action="/update";
            document.pay.method="post";
            document.pay.submit();
        }
        function Save() {
            document.pay.action = "/save";
            document.pay.method="post";
            document.pay.submit();
        }
    </script>
</head>

<body class="sticky-header">

<section>
    <!-- 左侧导航栏-->
    <div th:replace="common::#leftmenu"></div>
    <!-- 左侧导航栏-->

    <!-- 主要内容 start-->
    <div class="main-content" >

        <!-- 头部导航 start-->
        <div th:replace="common::#headermenu"></div>
        <!-- 头部导航 end-->

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                Editable Table
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Dashboard</a>
                </li>
                <li>
                    <a href="#">Data Table</a>
                </li>
                <li class="active"> Editable Table </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
             <div class="row">
                <div class="col-sm-12">
                <section class="panel">
                <header class="panel-heading">
                    Editable Table
                    <span class="tools pull-right">
                        <a href="javascript:;" class="fa fa-chevron-down"></a>
                        <a href="javascript:;" class="fa fa-times"></a>
                     </span>
                </header>
                <div class="panel-body">
                <div class="adv-table editable-table ">
                <div class="clearfix">
                    <div class="btn-group">
                        <button id="show" class="btn btn-primary">
                            Add New <i class="fa fa-plus"></i>
                        </button>
                        <form method="post" action="/upload" enctype="multipart/form-data">
                            请选择你要上传的文件<br>
                            <input type="file" name="file">
                            <input type="submit" value="上传">
                        </form>
                    </div>
                    <div class="btn-group pull-right">
                        <!--点击按钮出现下拉列表-->
                        <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Tools <i class="fa fa-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="#">Print</a></li>
                            <li><a href="#">Save as PDF</a></li>
                            <li><a href="#">Export to Excel</a></li>
                        </ul>
                    </div>
                </div>
                <div class="space15"></div>

                    <div style="width: 100%;height: 50px;padding: 10px 0 100px 0;display:none;" id="hide">
                        <form action="" name="pay" method="post" enctype="multipart/form-data">
                        <table class="table table-striped table-hover table-bordered">
                            <thead>
                            <tr>
                                <th>id</th>
                                <th>code</th>
                                <th>money</th>
                                <th>picture</th>
                                <th>编辑=id</th>
                                <th>保存！=id</th>
                                <th>删除=id</th>
                            </tr>
                            </thead>
                            <tbody role="alert" aria-live="polite" aria-relevant="all">
                            <tr class="odd">
                                <td for="add_id"><input type="text" class="form-control small" name="id"></td>
                                <td for="add_code"><input type="text" class="form-control small" name="code"></td>
                                <td for="add_money"><input type="text" class="form-control small" name="money"></td>
                                <td>
                                    <select id="select_picture" name="select_picture">
                                        <option th:each="all : ${allImg}" th:value="${all.imgname}">
                                            <span th:text="${all.imgname}"></span>
                                        </option>
                                    </select> 
                                </td>
                                <td><a class="ete" onclick="Edit()";>Edit</a></td>
                                <td><a class="edit" onclick="Save()";>Save</a></td>
                                <td><a class="delete" onclick="Save()";>delete</a></td>
                            </tr>
                            </tbody>
                        </table>
                           </form>
<!--                        </form>-->
                    </div>

                <table class="table table-striped table-hover table-bordered" id="editable-sample">

                <thead>
                <tr>
                    <th>picture</th>
                    <th>money</th>
                    <th>id</th>
                    <th>code</th>
                    <th><Del></Del>ete</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="order : ${orderList}">
                    <td th:text="${order.picture}"></td>
                    <td th:text="${order.money}"></td>
                    <td th:text="${order.id}"></td>
                    <td th:text="${order.code}"></td>
                    <td><a th:href="@{/delete(id=${order.id})}" method="post">Delete</a></td>
                </tr>
                </tbody>
                </table>
                </div>
                </div>
                </section>
                </div>

                </div>

        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by <a href="http://www.mycodes.net/" target="_blank">源码之家</a>
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>

<!-- Placed js at the end of the document so the pages load faster -->
<script th:src="@{/js/jquery-1.10.2.min.js}"></script>
<script th:src="@{/js/jquery-ui-1.9.2.custom.min.js}"></script>
<script th:src="@{/js/jquery-migrate-1.2.1.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/modernizr.min.js}"></script>
<script th:src="@{/js/jquery.nicescroll.js}"></script>

<!--data table-->
<script type="text/javascript" src="js/data-tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/data-tables/DT_bootstrap.js"></script>

<!--common scripts for all pages-->
<script src="js/scripts.js"></script>

<!--script for editable table-->
<script src="js/editable-table.js"></script>

<!-- END JAVASCRIPTS -->
<script>
    jQuery(document).ready(function() {
        EditableTable.init();
    });
</script>

</body>
</html>
